package test_net;

import com.google.gson.Gson;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

//必须是抽象类
public abstract class TestHttpCallback<T> extends AbsTestCallback<HttpResult<T>> {
    @Override
    public HttpResult<T> convert(String json) {
        Type type = getClass().getGenericSuperclass();
        Type[] types = ((ParameterizedType) type).getActualTypeArguments();
        ParameterizedTypeImpl ty = new ParameterizedTypeImpl(HttpResult.class, new Type[]{types[0]});
        return new Gson().fromJson(json, ty);
    }


}
